// Copyright (C) 2018 ~ 2020 Uniontech Technology Co., Ltd.
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "themeappicon.h"

#include <QPixmap>
#include <QDebug>
#include <QApplication>
#include <QFile>
#include <QDate>

#include <gtest/gtest.h>

class Ut_ThemeAppIcon : public ::testing::Test
{
public:
    virtual void SetUp() override;
    virtual void TearDown() override;
};

void Ut_ThemeAppIcon::SetUp()
{
    ThemeAppIcon icon;
}

void Ut_ThemeAppIcon::TearDown()
{
}

TEST_F(Ut_ThemeAppIcon, getIcon_test1)
{
    QPixmap pix;

    // 无效图标
    QString name = "123";
    ThemeAppIcon::getIcon(name);

    // 有效图标
    ThemeAppIcon::getIcon("dde-calendar");

    ThemeAppIcon::getIcon(pix, "", 50);
    ThemeAppIcon::getIcon(pix, "", 50, true);

    // 获取base64编码的png图片数据
    const QString &iconName = "";
    ThemeAppIcon::getIcon(pix, iconName, 60);
}

TEST_F(Ut_ThemeAppIcon, getIcon_test2)
{
    QPixmap pix;
    ThemeAppIcon::getIcon(pix, "dde-calendar", 50);
    ASSERT_TRUE(true);
}

TEST_F(Ut_ThemeAppIcon, getIcon_test3)
{
    QPixmap pix;
    ThemeAppIcon::getIcon(pix, "data:image/test", 50);
    ASSERT_FALSE(pix.isNull());
}

TEST_F(Ut_ThemeAppIcon, getIcon_test4)
{
    QPixmap pix;
    ThemeAppIcon::getIcon(pix, ":/res/all_settings_on.png", 50);
    ASSERT_FALSE(pix.isNull());
}

TEST_F(Ut_ThemeAppIcon, createCalendarIcon_test)
{
    const QString &filePath = "/tmp/calendar.svg";
    ASSERT_TRUE(ThemeAppIcon::createCalendarIcon(QDate::currentDate(), filePath));
    QFile::remove(filePath);
}
